package org.wikinews.en.wikinewsreader;

import android.os.Parcel;
import android.os.Parcelable;

public class News implements Parcelable{
    private Integer id;
    private String title;
    private String url;
    private String fulltext;
    private Integer revid;
    private String lastUpdate;

    public Integer getNewsID() {
    	return id;
    }
    public void setNewsID(Integer id) {
    	this.id = id;
    }
    
    public String getNewsTitle() {
        return title;
    }
    public void setNewsTitle(String title) {
        this.title = title;
    }

    public String getNewsURL() {
        return url;
    }
    public void setNewsURL(String url) {
        this.url = url;
    }
    
    public String getNewsFulltext() {
        return fulltext;
    }
    public void setNewsFulltext(String fulltext) {
        this.fulltext = fulltext;
    }

    public Integer getNewsRevid() {
    	return revid;
    }
    public void setNewsRevid(Integer revid) {
    	this.revid = revid;
    }

    public String getNewsLastUpdate() {
        return lastUpdate;
    }
    public void setNewsLastUpdate(String lastUpdate) {
        this.lastUpdate = lastUpdate;
    }
    
    // Parcelable example from:
    // http://developer.android.com/reference/android/os/Parcelable.html
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		/*
		 * Every code attempt I've made, causes crash. So far this works empty.
		 * I don't know how it is storing the data. I don't know why... 
		 * ...and frankly I gave up trying to understand it at about 0100 in the morning. 
		 */
		
		//Log.d("WikinewsReader","writeToParcel()");
		//String[] a = {getNewsID().toString(), getNewsTitle().toString(), getNewsURL().toString(), getNewsFulltext().toString(), getNewsRevid().toString(), getNewsLastUpdate().toString()};
		//dest.writeStringArray(a);
	}
	
	public static final Parcelable.Creator<News> CREATOR = new Parcelable.Creator<News>() {
		public News createFromParcel(Parcel in){
			return new News(in);
		}
		public News[] newArray(int size){
			return new News[size];			
		}
	};
	
	News(Parcel in){
		//Need this for the creator call.
		
			/*if(in != null){
				String[] a = null;
				in.readStringArray(a);
				setNewsID(Integer.parseInt(a[0]));
				setNewsTitle(a[1]);
				setNewsURL(a[2]);
				setNewsFulltext(a[3]);
				setNewsRevid(Integer.parseInt(a[4]));
				setNewsLastUpdate(a[5]);
			}*/
	}
}
